#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
+#include "llvm/ADT/Triple.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileUtilities.h"
// The possible structures are:
// - ${ROCM_ROOT}/amdgcn/bitcode/*
// - ${ROCM_ROOT}/lib/*
+ // - ${ROCM_ROOT}/lib/<multiarch>/amdgcn/bitcode/*
// - ${ROCM_ROOT}/lib/bitcode/*
- // so try to detect these layouts.
- static constexpr std::array<const char *, 2> SubDirsList[] = {
- {"amdgcn", "bitcode"},
- {"lib", ""},
- {"lib", "bitcode"},
+ // so try to detect these layouts. Note that bitcode is associated with the
+ // compiler that built it (not the target architecture).
+ llvm::Triple HostTriple(llvm::sys::getProcessTriple());
+ std::string Multiarch = Twine(HostTriple.getArchName() + "-linux-gnu").str();
+ static const std::array<std::string, 4> SubDirsList[] = {
+ {"amdgcn", "bitcode", "", ""},
+ {"lib", "", "", ""},
+ {"lib", Multiarch, "amdgcn", "bitcode"},
+ {"lib", "bitcode", "", ""},
};
// Make a path by appending sub-directories to InstallPath.
- auto MakePath = [&](const llvm::ArrayRef<const char *> &SubDirs) {
+ auto MakePath = [&](const llvm::ArrayRef<std::string> &SubDirs) {
auto Path = CandidatePath;
for (auto SubDir : SubDirs)
llvm::sys::path::append(Path, SubDir);